//
//  NetWorkTools.h
//  FSEDU
//
//  Created by 张晓伟 on 2018/6/23.
//  Copyright © 2018年 青岛广电传媒电子商务有限公司. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking.h>

typedef enum : NSInteger
{
    GET,
    POST
} RequestMethod;

@interface NetWorkTools : NSObject
/**成功回调block*/
typedef void(^HttpSuccessBlock)(id responseObject);
/**缓存回调block*/
typedef void(^HttpCacheBlock)(id cacheObject);
/**失败回调block*/
typedef void(^HttpFailureBlock)(NSError *error);
/**上传回调block*/
typedef void(^UploadSuccessBlock)(NSString *urls);
/**进度回调block*/
typedef void(^ProgressBlock)(float progress);

+ (AFHTTPSessionManager *)sharedHttpSession;

/// json 格式请求 json 字符串方式
/// @param urlStr urlStr
/// @param params params
/// @param success success
/// @param failure failure
+ (void)jsonFormat_requestURLStr:(NSString *)urlStr params:(NSDictionary *)params success:(HttpSuccessBlock)success failure:(HttpFailureBlock)failure;

/**
 数据请求(不带缓存)
 
 @param urlStr 路径
 @param method get/post方法
 @param params 参数
 @param success 成功回调
 @param failure 失败回调
 */
+ (void)requestWithURLStr:(NSString *)urlStr method:(RequestMethod)method params:(NSDictionary *)params success:(HttpSuccessBlock)success failure:(HttpFailureBlock)failure;

/**
 数据请求(带缓存)
 
 @param urlStr 路径
 @param method get/post方法
 @param params 参数
 @param cache  缓存
 @param success 成功回调
 @param failure 失败回调
 */
+ (void)requestWithURLStr:(NSString *)urlStr method:(RequestMethod)method params:(NSDictionary *)params cache:(HttpCacheBlock)cache success:(HttpSuccessBlock)success failure:(HttpFailureBlock)failure;



#pragma mark 上传单张图片
+ (void)uploadImageWithImage:(UIImage *)image success:(UploadSuccessBlock)success failure:(HttpFailureBlock)failure progress:(ProgressBlock)progress;


#pragma mark 上传多张图片
+ (void)uploadWithPhotos:(NSArray<UIImage *> *)photos  success:(UploadSuccessBlock)success failure:(HttpFailureBlock)failure progress:(ProgressBlock)progress;

@end
